import Cesium from '@czm';
import {
  G3xObjBase,
  G3vObj
} from "@g3xObj"
import * as g3xUtils from "@g3x/utils";
import {
  autorun,
  reaction,
  intercept,
  extendObservable,
  computed
} from 'mobx';

/**
 * 路径
 * @memberof Obj
 * @class
 * @extends XbsjCzmObj
 */
class G3xPath extends G3vObj {

  constructor(g3vviewer, options) {

    super(options);

    this.init()
  }

  init() {
    var _this = this;
    const {
      viewer,
      disposers,
      position,
      path
    } = this;

    //Actually create the entity
    const entityOptions = {
      //Set the entity availability to the same interval as the simulation time.
      availability: new Cesium.TimeIntervalCollection([
        new Cesium.TimeInterval({
          start: start,
          stop: stop
        })
      ]),

      //Use our computed positions
      position,

      //Automatically compute orientation based on position movement.
      orientation: new Cesium.VelocityOrientationProperty(position),

      //Load the Cesium plane model to represent the entity
      model: {
        uri: '//zzgis.com/cdn/3d/SampleData/models/CesiumAir/Cesium_Air.glb',
        minimumPixelSize: 64
      },

      label: {
        text: "aircraft",
        showBackground: true,
        horizontalOrigin: Cesium.HorizontalOrigin.LEFT,
        verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
      },

      // plane: plane,

      //Show the path as a pink line sampled in 1 second increments.
      path: {
        resolution: 0.2,
        width: 50,
        material
      }
    };
    var entity = viewer.entities.add(entityOptions);
  };

  getEntityOptions(){
    var _this = this;
    const {
      viewer,
      disposers,
      availability,
      position,
      path
    } = this;

    const availability = new Cesium.TimeIntervalCollection([
        new Cesium.TimeInterval({
          start: start,
          stop: stop
        })
      ]);

    //Actually create the entity
    const entityOptions = {
      //Set the entity availability to the same interval as the simulation time.
      availability,

      //Use our computed positions
      position,

      //Automatically compute orientation based on position movement.
      orientation: new Cesium.VelocityOrientationProperty(position),

      //Load the Cesium plane model to represent the entity
      model: {
        uri: '//zzgis.com/cdn/3d/SampleData/models/CesiumAir/Cesium_Air.glb',
        minimumPixelSize: 64
      },

      label: {
        text: "aircraft",
        showBackground: true,
        horizontalOrigin: Cesium.HorizontalOrigin.LEFT,
        verticalOrigin: Cesium.VerticalOrigin.BOTTOM,
      },

      // plane: plane,

      //Show the path as a pink line sampled in 1 second increments.
      path: {
        resolution: 0.2,
        width: 50,
        material
      }
    };
  }
}

// https://cesium.com/learn/cesiumjs/ref-doc/Entity.html#.ConstructorOptions
G3xPath.defaultOptions = {
  id,
  name,
  show,
  description,
  timeIntervals: undefined, // options: Cesium.TimeInterval.fromIso8601(options, result)
  position: [],
  orientation,
  path: {
    resolution: 0.2,
    width: 50,
    material
  },
  material: '',
}
